\(\int (a+i a \tan (e+f x))^2 (c+d \tan (e+f x)) \, dx\) [1066]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [A] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 26, antiderivative size = 80 \[ \int (a+i a \tan (e+f x))^2 (c+d \tan (e+f x)) \, dx=2 a^2 (c-i d) x-\frac {2 a^2 (i c+d) \log (\cos (e+f x))}{f}-\frac {a^2 (c-i d) \tan (e+f x)}{f}+\frac {d (a+i a \tan (e+f x))^2}{2 f} \]

[Out]

2*a^2*(c-I*d)*x-2*a^2*(I*c+d)*ln(cos(f*x+e))/f-a^2*(c-I*d)*tan(f*x+e)/f+1/2*d*(a+I*a*tan(f*x+e))^2/f

Rubi [A] (verified)

Time = 0.09 (sec) , antiderivative size = 80, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.115, Rules used = {3608, 3558, 3556} \[ \int (a+i a \tan (e+f x))^2 (c+d \tan (e+f x)) \, dx=-\frac {a^2 (c-i d) \tan (e+f x)}{f}-\frac {2 a^2 (d+i c) \log (\cos (e+f x))}{f}+2 a^2 x (c-i d)+\frac {d (a+i a \tan (e+f x))^2}{2 f} \]

[In]

Int[(a + I*a*Tan[e + f*x])^2*(c + d*Tan[e + f*x]),x]

[Out]

2*a^2*(c - I*d)*x - (2*a^2*(I*c + d)*Log[Cos[e + f*x]])/f - (a^2*(c - I*d)*Tan[e + f*x])/f + (d*(a + I*a*Tan[e
 + f*x])^2)/(2*f)

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3558

Int[((a_) + (b_.)*tan[(c_.) + (d_.)*(x_)])^2, x_Symbol] :> Simp[(a^2 - b^2)*x, x] + (Dist[2*a*b, Int[Tan[c + d
*x], x], x] + Simp[b^2*(Tan[c + d*x]/d), x]) /; FreeQ[{a, b, c, d}, x]

Rule 3608

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[d*(
(a + b*Tan[e + f*x])^m/(f*m)), x] + Dist[(b*c + a*d)/b, Int[(a + b*Tan[e + f*x])^m, x], x] /; FreeQ[{a, b, c,
d, e, f, m}, x] && NeQ[b*c - a*d, 0] && EqQ[a^2 + b^2, 0] &&  !LtQ[m, 0]

Rubi steps \begin{align*} \text {integral}& = \frac {d (a+i a \tan (e+f x))^2}{2 f}-(-c+i d) \int (a+i a \tan (e+f x))^2 \, dx \\ & = 2 a^2 (c-i d) x-\frac {a^2 (c-i d) \tan (e+f x)}{f}+\frac {d (a+i a \tan (e+f x))^2}{2 f}+\left (2 a^2 (i c+d)\right ) \int \tan (e+f x) \, dx \\ & = 2 a^2 (c-i d) x-\frac {2 a^2 (i c+d) \log (\cos (e+f x))}{f}-\frac {a^2 (c-i d) \tan (e+f x)}{f}+\frac {d (a+i a \tan (e+f x))^2}{2 f} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.52 (sec) , antiderivative size = 58, normalized size of antiderivative = 0.72 \[ \int (a+i a \tan (e+f x))^2 (c+d \tan (e+f x)) \, dx=\frac {a^2 \left (d+4 (i c+d) \log (i+\tan (e+f x))-2 (c-2 i d) \tan (e+f x)-d \tan ^2(e+f x)\right )}{2 f} \]

[In]

Integrate[(a + I*a*Tan[e + f*x])^2*(c + d*Tan[e + f*x]),x]

[Out]

(a^2*(d + 4*(I*c + d)*Log[I + Tan[e + f*x]] - 2*(c - (2*I)*d)*Tan[e + f*x] - d*Tan[e + f*x]^2))/(2*f)

Maple [A] (verified)

Time = 0.22 (sec) , antiderivative size = 76, normalized size of antiderivative = 0.95

method result size
derivativedivides \(\frac {a^{2} \left (-\frac {d \left (\tan ^{2}\left (f x +e \right )\right )}{2}-c \tan \left (f x +e \right )+2 i \tan \left (f x +e \right ) d +\frac {\left (2 i c +2 d \right ) \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{2}+\left (-2 i d +2 c \right ) \arctan \left (\tan \left (f x +e \right )\right )\right )}{f}\) \(76\)
default \(\frac {a^{2} \left (-\frac {d \left (\tan ^{2}\left (f x +e \right )\right )}{2}-c \tan \left (f x +e \right )+2 i \tan \left (f x +e \right ) d +\frac {\left (2 i c +2 d \right ) \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{2}+\left (-2 i d +2 c \right ) \arctan \left (\tan \left (f x +e \right )\right )\right )}{f}\) \(76\)
norman \(\left (-2 i a^{2} d +2 a^{2} c \right ) x -\frac {\left (-2 i a^{2} d +a^{2} c \right ) \tan \left (f x +e \right )}{f}-\frac {a^{2} d \left (\tan ^{2}\left (f x +e \right )\right )}{2 f}+\frac {\left (i a^{2} c +a^{2} d \right ) \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{f}\) \(87\)
parallelrisch \(\frac {-4 i x \,a^{2} d f +2 i \ln \left (1+\tan ^{2}\left (f x +e \right )\right ) a^{2} c +4 i \tan \left (f x +e \right ) a^{2} d +4 x \,a^{2} c f -a^{2} d \left (\tan ^{2}\left (f x +e \right )\right )+2 \ln \left (1+\tan ^{2}\left (f x +e \right )\right ) a^{2} d -2 \tan \left (f x +e \right ) a^{2} c}{2 f}\) \(98\)
parts \(a^{2} c x +\frac {\left (2 i a^{2} c +a^{2} d \right ) \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{2 f}+\frac {\left (2 i a^{2} d -a^{2} c \right ) \left (\tan \left (f x +e \right )-\arctan \left (\tan \left (f x +e \right )\right )\right )}{f}-\frac {a^{2} d \left (\frac {\left (\tan ^{2}\left (f x +e \right )\right )}{2}-\frac {\ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{2}\right )}{f}\) \(104\)
risch \(\frac {4 i a^{2} d e}{f}-\frac {4 a^{2} c e}{f}-\frac {2 a^{2} \left (i c \,{\mathrm e}^{2 i \left (f x +e \right )}+3 \,{\mathrm e}^{2 i \left (f x +e \right )} d +i c +2 d \right )}{f \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right )^{2}}-\frac {2 a^{2} \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) d}{f}-\frac {2 i a^{2} \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) c}{f}\) \(120\)

[In]

int((a+I*a*tan(f*x+e))^2*(c+d*tan(f*x+e)),x,method=_RETURNVERBOSE)

[Out]

1/f*a^2*(-1/2*d*tan(f*x+e)^2-c*tan(f*x+e)+2*I*d*tan(f*x+e)+1/2*(2*d+2*I*c)*ln(1+tan(f*x+e)^2)+(2*c-2*I*d)*arct
an(tan(f*x+e)))

Fricas [A] (verification not implemented)

none

Time = 0.24 (sec) , antiderivative size = 135, normalized size of antiderivative = 1.69 \[ \int (a+i a \tan (e+f x))^2 (c+d \tan (e+f x)) \, dx=-\frac {2 \, {\left (i \, a^{2} c + 2 \, a^{2} d + {\left (i \, a^{2} c + 3 \, a^{2} d\right )} e^{\left (2 i \, f x + 2 i \, e\right )} + {\left (i \, a^{2} c + a^{2} d + {\left (i \, a^{2} c + a^{2} d\right )} e^{\left (4 i \, f x + 4 i \, e\right )} + 2 \, {\left (i \, a^{2} c + a^{2} d\right )} e^{\left (2 i \, f x + 2 i \, e\right )}\right )} \log \left (e^{\left (2 i \, f x + 2 i \, e\right )} + 1\right )\right )}}{f e^{\left (4 i \, f x + 4 i \, e\right )} + 2 \, f e^{\left (2 i \, f x + 2 i \, e\right )} + f} \]

[In]

integrate((a+I*a*tan(f*x+e))^2*(c+d*tan(f*x+e)),x, algorithm="fricas")

[Out]

-2*(I*a^2*c + 2*a^2*d + (I*a^2*c + 3*a^2*d)*e^(2*I*f*x + 2*I*e) + (I*a^2*c + a^2*d + (I*a^2*c + a^2*d)*e^(4*I*
f*x + 4*I*e) + 2*(I*a^2*c + a^2*d)*e^(2*I*f*x + 2*I*e))*log(e^(2*I*f*x + 2*I*e) + 1))/(f*e^(4*I*f*x + 4*I*e) +
 2*f*e^(2*I*f*x + 2*I*e) + f)

Sympy [A] (verification not implemented)

Time = 0.30 (sec) , antiderivative size = 122, normalized size of antiderivative = 1.52 \[ \int (a+i a \tan (e+f x))^2 (c+d \tan (e+f x)) \, dx=- \frac {2 i a^{2} \left (c - i d\right ) \log {\left (e^{2 i f x} + e^{- 2 i e} \right )}}{f} + \frac {- 2 i a^{2} c - 4 a^{2} d + \left (- 2 i a^{2} c e^{2 i e} - 6 a^{2} d e^{2 i e}\right ) e^{2 i f x}}{f e^{4 i e} e^{4 i f x} + 2 f e^{2 i e} e^{2 i f x} + f} \]

[In]

integrate((a+I*a*tan(f*x+e))**2*(c+d*tan(f*x+e)),x)

[Out]

-2*I*a**2*(c - I*d)*log(exp(2*I*f*x) + exp(-2*I*e))/f + (-2*I*a**2*c - 4*a**2*d + (-2*I*a**2*c*exp(2*I*e) - 6*
a**2*d*exp(2*I*e))*exp(2*I*f*x))/(f*exp(4*I*e)*exp(4*I*f*x) + 2*f*exp(2*I*e)*exp(2*I*f*x) + f)

Maxima [A] (verification not implemented)

none

Time = 0.41 (sec) , antiderivative size = 83, normalized size of antiderivative = 1.04 \[ \int (a+i a \tan (e+f x))^2 (c+d \tan (e+f x)) \, dx=-\frac {a^{2} d \tan \left (f x + e\right )^{2} - 4 \, {\left (a^{2} c - i \, a^{2} d\right )} {\left (f x + e\right )} - 2 \, {\left (i \, a^{2} c + a^{2} d\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right ) + 2 \, {\left (a^{2} c - 2 i \, a^{2} d\right )} \tan \left (f x + e\right )}{2 \, f} \]

[In]

integrate((a+I*a*tan(f*x+e))^2*(c+d*tan(f*x+e)),x, algorithm="maxima")

[Out]

-1/2*(a^2*d*tan(f*x + e)^2 - 4*(a^2*c - I*a^2*d)*(f*x + e) - 2*(I*a^2*c + a^2*d)*log(tan(f*x + e)^2 + 1) + 2*(
a^2*c - 2*I*a^2*d)*tan(f*x + e))/f

Giac [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 214 vs. \(2 (70) = 140\).

Time = 0.44 (sec) , antiderivative size = 214, normalized size of antiderivative = 2.68 \[ \int (a+i a \tan (e+f x))^2 (c+d \tan (e+f x)) \, dx=-\frac {2 \, {\left (i \, a^{2} c e^{\left (4 i \, f x + 4 i \, e\right )} \log \left (e^{\left (2 i \, f x + 2 i \, e\right )} + 1\right ) + a^{2} d e^{\left (4 i \, f x + 4 i \, e\right )} \log \left (e^{\left (2 i \, f x + 2 i \, e\right )} + 1\right ) + 2 i \, a^{2} c e^{\left (2 i \, f x + 2 i \, e\right )} \log \left (e^{\left (2 i \, f x + 2 i \, e\right )} + 1\right ) + 2 \, a^{2} d e^{\left (2 i \, f x + 2 i \, e\right )} \log \left (e^{\left (2 i \, f x + 2 i \, e\right )} + 1\right ) + i \, a^{2} c e^{\left (2 i \, f x + 2 i \, e\right )} + 3 \, a^{2} d e^{\left (2 i \, f x + 2 i \, e\right )} + i \, a^{2} c \log \left (e^{\left (2 i \, f x + 2 i \, e\right )} + 1\right ) + a^{2} d \log \left (e^{\left (2 i \, f x + 2 i \, e\right )} + 1\right ) + i \, a^{2} c + 2 \, a^{2} d\right )}}{f e^{\left (4 i \, f x + 4 i \, e\right )} + 2 \, f e^{\left (2 i \, f x + 2 i \, e\right )} + f} \]

[In]

integrate((a+I*a*tan(f*x+e))^2*(c+d*tan(f*x+e)),x, algorithm="giac")

[Out]

-2*(I*a^2*c*e^(4*I*f*x + 4*I*e)*log(e^(2*I*f*x + 2*I*e) + 1) + a^2*d*e^(4*I*f*x + 4*I*e)*log(e^(2*I*f*x + 2*I*
e) + 1) + 2*I*a^2*c*e^(2*I*f*x + 2*I*e)*log(e^(2*I*f*x + 2*I*e) + 1) + 2*a^2*d*e^(2*I*f*x + 2*I*e)*log(e^(2*I*
f*x + 2*I*e) + 1) + I*a^2*c*e^(2*I*f*x + 2*I*e) + 3*a^2*d*e^(2*I*f*x + 2*I*e) + I*a^2*c*log(e^(2*I*f*x + 2*I*e
) + 1) + a^2*d*log(e^(2*I*f*x + 2*I*e) + 1) + I*a^2*c + 2*a^2*d)/(f*e^(4*I*f*x + 4*I*e) + 2*f*e^(2*I*f*x + 2*I
*e) + f)

Mupad [B] (verification not implemented)

Time = 5.89 (sec) , antiderivative size = 76, normalized size of antiderivative = 0.95 \[ \int (a+i a \tan (e+f x))^2 (c+d \tan (e+f x)) \, dx=\frac {\mathrm {tan}\left (e+f\,x\right )\,\left (a^2\,d\,1{}\mathrm {i}+a^2\,\left (d+c\,1{}\mathrm {i}\right )\,1{}\mathrm {i}\right )}{f}+\frac {\ln \left (\mathrm {tan}\left (e+f\,x\right )+1{}\mathrm {i}\right )\,\left (2\,a^2\,d+a^2\,c\,2{}\mathrm {i}\right )}{f}-\frac {a^2\,d\,{\mathrm {tan}\left (e+f\,x\right )}^2}{2\,f} \]

[In]

int((a + a*tan(e + f*x)*1i)^2*(c + d*tan(e + f*x)),x)

[Out]

(tan(e + f*x)*(a^2*d*1i + a^2*(c*1i + d)*1i))/f + (log(tan(e + f*x) + 1i)*(a^2*c*2i + 2*a^2*d))/f - (a^2*d*tan
(e + f*x)^2)/(2*f)